﻿using Microsoft.Practices.Unity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MusicManagerDAO.Interfaces;
using MusicManagerDAO.Implementation;
using MusicManager.BL;
//using MusicManagerBL = MusicManagerBL.MusicManagerBL;

namespace Test
{
    class Program
    {
        [Dependency]
        private static IMusicManagerBL BL { get; set; }

        static void Main(string[] args)
        {
            IUnityContainer container = new UnityContainer();
            // DAOs
            container.RegisterType<IUserDao, UserDao>(new HierarchicalLifetimeManager());
            container.RegisterType<IMusicDao, MusicDao>(new HierarchicalLifetimeManager());

            // Business Logic
            container.RegisterType<IMusicManagerBL, MusicManager.BL.MusicManagerBLMediaServicecs>(new HierarchicalLifetimeManager());
            var instance = container.Resolve<MusicManager.BL.MusicManagerBLMediaServicecs>();
            BL = new MusicManager.BL.MusicManagerBLMediaServicecs();
            (BL as MusicManager.BL.MusicManagerBLMediaServicecs).UserDao = instance.UserDao;
            (BL as MusicManager.BL.MusicManagerBLMediaServicecs).MusicDao = instance.MusicDao;

            Database.Init(BL);
            Console.ReadLine();
        }
    }
}
